package com.aac.rfcrabbitmvc.consumer;

import com.aac.rfcrabbitmvc.constant.Queues;
import com.aac.rfcrabbitmvc.producer.RequestMapProducer;
import com.aac.rfcrabbitmvc.service.BpmToSapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class RequestMapConsumer {

    @Autowired
    private RequestMapProducer requestMapProducer;

    @Autowired
    private BpmToSapService bpmToSapService;

    public void listenRequestMap(Map<String, Object> requestMap) {
        Map<String, Object> responseMap = bpmToSapService.getSapJson(requestMap);
        String requestID = (String) requestMap.get("requestID");
        int reqQNo = (int) requestMap.get("reqQNo");
        responseMap.put("responseID", requestID);
        responseMap.put("resQNo", reqQNo);
        requestMapProducer.sendResponseMap(Queues.RESPONSE_QUEUE + reqQNo, responseMap);
    }

}
